﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;

namespace Puddy
{
    [DataContract()]
    public class FoursquarePlaceResponce
    {



        [DataMember(Name = "response")]
        public Venues Renues { get; set; }

        public FoursquarePlaceResponce()
        {
            
        }

        public static FoursquarePlaceResponce ParseFromJSON(String jsonData)
        {

            FoursquarePlaceResponce  output;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(FoursquarePlaceResponce));
            using (MemoryStream stream =  new MemoryStream(Encoding.Unicode.GetBytes(jsonData)))
            {
                output =  serializer.ReadObject(stream) as FoursquarePlaceResponce;
            }
            return output;
        }
    }


    [DataContract()]
    public class Venues
    {
        [DataMember(Name = "venues")]
        public List<FoursquarePlace> Places { get; set; }

        public Venues ()
        {
            Places = new List<FoursquarePlace>();
        }
    }

    [DataContract()]
    public class FoursquarePlace
    {

        public FoursquarePlace()
        {

        }

        [DataMember(Name = "name")]
        public string Name { get; set; }


        [DataMember(Name = "location")]
        public geometry Location { get; set; }

    }


    [DataContract()]
    public class geometry
    {
        [DataMember(Name = "address")]
        public String Address { get; set; }

        [DataMember(Name = "city")]
        public String City { get; set; }

        [DataMember(Name = "state")]
        public String State { get; set; }

        [DataMember(Name = "country")]
        public String Country { get; set; }

        [DataMember(Name = "lat")]
        public double Lattitude { get; set; }

        [DataMember(Name = "lng")]
        public double Longitude { get; set; }

    }
    
}
